home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / programming / c / amiga-c / files / easyopen.c < prev   
C/C++ Source or Header  |  1999-06-14  |  2KB  |  32 lines

  1. /* easy.c: a complete example of how to open an Amiga function library in
  2.  * C. In this case the function library is Intuition.  Once the Intuition
  3.  * function library is open, any Intuition function can be called.  This
  4.  * example uses the DisplayBeep() function of Intuition to flash the
  5.  * screen With SAS/C (Lattice), compile with lc -L easy.c
  6.  */
  7.  
  8. /* Declare the return type of the functions we will use.                 */
  9. struct Library *OpenLibrary();  /* These Exec library functions can be   */
  10. void            CloseLibrary(); /* called anytime (Exec is always open). */
  11.  
  12. void            DisplayBeep();  /* Before using this Intuition function, */
  13.                                 /* the Intuition library must be opened  */
  14.  
  15. struct IntuitionBase *IntuitionBase; /* Get storage for the library base */
  16.                                      /* The base name MUST be            */
  17.                                      /* IntuitionBase                    */
  18. int main()
  19. {
  20.     IntuitionBase=(struct IntuitionBase *)
  21.                   OpenLibrary("intuition.library",33L);
  22.     if(IntuitionBase)           /* Check to see if it actually opened.   */
  23.         {                       /* The Intuition library is now open so  */
  24.         DisplayBeep(0L);        /* any of its functions may be used.     */
  25.         CloseLibrary(IntuitionBase); /* Always close a library if not    */
  26.                                      /* in use.                          */
  27.         }
  28.     else                        /* The library did not open so return an */
  29.        {                        /* error code.  The exit() function is   */
  30.        exit(20);                /* not part of the OS, it is part of the */
  31.        }                        /* compiler link library.                */
  32. }